﻿using System.Xml;

namespace DictionaryProcesser;

class Program
{
    static void Main(string[] args)
    {
        string path = args[0];
        string[] result;
        using (StreamReader streamReader = new StreamReader(path))
        {
            string line;
            while ((line = streamReader.ReadLine()) != null)
            {
                result = line.Split('【', '】');

                XmlDocument xmlDocument = new XmlDocument();
                XmlDeclaration xmlDeclaration = xmlDocument.CreateXmlDeclaration("1.0", "utf-8", null);
                xmlDocument.AppendChild(xmlDeclaration);
                XmlElement root = xmlDocument.CreateElement("Entry");
                xmlDocument.AppendChild(root);
                XmlElement word = xmlDocument.CreateElement("Word");
                word.InnerText = result[1];
                root.AppendChild(word);
                XmlElement pronunciation = xmlDocument.CreateElement("Pronunciation");
                pronunciation.InnerText = "";
                root.AppendChild(pronunciation);
                XmlElement definition = xmlDocument.CreateElement("Definition");
                definition.InnerText = result[2];
                root.AppendChild(definition);
                xmlDocument.Save($"/home/zhchmmx/Dictionary/xdhycd7/{result[1]}.xml");
            }
        }
    }
}